"""
添加付款单
"""

from page.base_page import BasePage
from selenium.webdriver.common.by import By


class FkdPage(BasePage):
    url = "http://192.168.1.25/crm/index.php?m=finance&a=add&t=paymentorder"

    # 定位器
    fkd_locator = (By.NAME,'payables')
    xz_yfk_locator = (By.CSS_SELECTOR, '#data > tr:nth-child(1) > td:nth-child(1) > input[type=radio]')
    xz_yfk_qd_locator = (By.CSS_SELECTOR,
                         'body > div:nth-child(8) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1)')
    fkje_locator = (By.ID, 'money')
    fksj_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[6]/td[2]/input')
    dxk_wjz_locator = (By.NAME, 'status')
    msnr_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div > form > table > tbody > tr:nth-child(8) > td:nth-child(2) > textarea')
    fkd_bc_btn_locator = (By.NAME, 'submit')
    fkd_qx_btn_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(3)')
    fkd_bcxj_btn_locator = (By.NAME, 'submit')
    # 操作方法
    # 点击应付款
    def click_yfk(self):
        self.driver.find_element(*self.fkd_locator).click()

    # 选择应付款人
    def click_xz_yfk(self):
        self.driver.find_element(*self.xz_yfk_locator).click()

    # 确定应付款人
    def click_xz_yfk_qd_btn(self):
        self.driver.find_element(*self.xz_yfk_qd_locator).click()

    # 输入应收款金额
    def input_fkje(self, fkje):
        self.driver.find_element(*self.fkje_locator).send_keys(fkje)

    # 输入收款时间
    def input_fksj(self, fksj):
        self.driver.find_element(*self.fksj_locator).send_keys(fksj)

    # 点击未结账状态
    def click_wjz(self):
        self.driver.find_element(*self.dxk_wjz_locator).click()

    # 输入描述内容
    def input_msnr(self, msnr):
        self.driver.find_element(*self.msnr_locator).send_keys(msnr)

    # 点击保存
    def click_bc_btn(self):
        self.driver.find_element(*self.fkd_bc_btn_locator).click()

    # 点击取消
    def click_qx_btn(self):
        self.driver.find_element(*self.fkd_qx_btn_locator).click()

    #点击保存并新建
    def click_bcxj_btn(self):
        self.driver.find_element(*self.fkd_bcxj_btn_locator).click()